﻿var a = 0;
var text;
var selects; //记录玩家的选项
var buynum = 0;
var itemlist = Array(
    Array(2430686, 1), //大姐大
    Array(1112947, 1), //梦幻悬浮戒指（单人版）
    Array(1112822, 1), //梦幻悬浮戒指（双人版）
    Array(2450130, 2000),//双倍白2430686
    Array(5530111, 5000), //潜能印章
    Array(2340000, 1000), //祝福卷轴
    Array(2049025, 5000), //白医卷轴
    Array(5530269, 10000), //附加印章
    Array(2430692, 500), //星云岩箱
    Array(5750000, 3000), //星岩魔方
    Array(5064000, 1000), //防爆卷轴
    Array(5064100, 2000), //保护卷轴
    Array(5050000, 1000), //洗能力点卷轴
    Array(5390018, 5000), //赤兔喇叭
    Array(5520000, 3000), //宿命剪刀
    Array(5520001, 5000), //白金宿命剪刀
    // Array(1012553, 30000),//咬紧牙关的面罩
    Array(5570000, 10000), //金锤子
    Array(4032933, 2000), //一朵玫瑰
    //ray(2610003, 2500),//封印解除卷轴
    Array(5840007, 1100), //椅子专用万花筒钥匙
    //ray(2590008, 1100),//特殊灵魂附魔石
    Array(5840006, 1100), //伤害皮肤万花筒钥匙
    Array(5840004, 1100), //怪怪卡包钥匙
    //Array(5840003, 1100),//转蛋万花筒钥匙
    Array(5192000, 1100), //宠物训练箱
    Array(5060049, 1100), //伤害皮肤卡包
    Array(5060052, 1100), //椅子工具包
    Array(5840000, 1100), //品克缤1阶
    Array(5840001, 1100), //品克缤2阶
    Array(5840002, 1100), //品克缤3阶    
    Array(5743003, 1500), //怪怪方块 
    // Array(5220006, 1100), //黑龙入场券    
    Array(2430780, 1100), //魔法袋
    Array(5190011, 1100), //宠物训练技能   
    Array(5537000, 1100), //怪怪卡包 
    Array(2435770, 1100)
);
var head = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n";

function start() {
    a = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 1)
            a++;
        else
            a--;
        if (a == -1) {
            cm.dispose();
        } else if (a == 0) {
            text = head + "#h0#,你好！在这里可以选择你想要购买的物品,点击图片购买\r\n#b";
            for (var i = 0; i < itemlist.length; i++) {
                text += "#L" + i + "##i" + itemlist[i] + "#";
                if (i != 0 && (i + 1) % 5 == 0) {
                    text += "\r\n";
                }
            }
            cm.sendSimple(text);
        } else if (a == 1) {
            selects = selection;
            cm.sendGetNumber("请输入你请你输入想要购买的数量\r\n\r\n#r - 1个需要" + itemlist[selects][1] + "点卷", 0, 0, 999999);
        } else if (a == 2) {
            buynum = selection;
            cm.sendNext("你想购买" + buynum + "个#r#i" + itemlist[selects][0] + "##k？\r\n你将使用掉" + (buynum * itemlist[selects][1]) + "点卷。");
        } else if (a == 3) {
            if (cm.getChar().getCSPoints(1) >= buynum * itemlist[selects][1]) {
                cm.getChar().modifyCSPoints(1, -buynum * itemlist[selects][1]);
                cm.gainItem(itemlist[selects][0], buynum);
                cm.sendOk("购买成功了！");
                cm.dispose();
            } else {
                cm.sendOk("对不起，你没有足够的点卷。");
                cm.dispose();
            }
        }
    } //mode
} //f